package components.game
{
	import SEApp.boxes.albums.se_previewItem;
	import SEApp.dialogs.se_buttonDialog;
	import SEApp.se_util;
	
	import UIFree.controls.uif_gbutton;
	import UIFree.controls.uif_hscrollArea;
	import UIFree.controls.uif_input;
	import UIFree.controls.uif_label;
	import UIFree.uif_component;
	import UIFree.uif_ecomponent;
	
	import components.dialogs.clt_dialog;
	
	import data.cd_stikers;
	import data.clt_data;
	
	import flash.events.Event;
	import flash.geom.Rectangle;
	
	public class clt_gameParams extends se_buttonDialog {
		private var _input		: uif_input;
		private var _stikers	: uif_hscrollArea;
		private static const STIKERSHEIGHT: int = 120;
		
		public function clt_gameParams(parent: uif_component, doOk: Function) {
			var a_height: int = 120;
			if ((parent.app as clt_clothingBase).user.vipStatus) a_height += STIKERSHEIGHT;
			super(parent, 0, 0, 500, a_height, true);
			title.text = clt.locale.GAMEPARAMSTITLE;
			this.createButtons(doOk, true);
		}
		
		protected function get clt(): clt_clothingBase {
			return app as clt_clothingBase;
		}
		
		override protected function createDialogComponents():void {
			super.createDialogComponents();
			var inner: Rectangle = getInner();
			var panel: uif_ecomponent = new uif_ecomponent(this, inner.x, inner.y, inner.width, 
										inner.height - se_util.DEFHEIGHTBUTTON, 'description');
			inner = panel.getInner();
			var info: uif_label;
			
			if (clt.user.vipStatus) {
				info = new uif_label(panel, inner.x, inner.y, inner.width, 20, 'desc');
				info.text = clt.locale.STIKERLISTDESCRIPTION;
				
				_stikers = new uif_hscrollArea(panel, inner.x, inner.y + info.height, inner.width, 92, 'items');
				
				var si: Rectangle = _stikers.displayRect;
				_stikers.assignList(cd_stikers.list, si.width / 4, function(_scroll: uif_component, inner: Rectangle, index: int): clt_stiker {
					var a_data: Object = cd_stikers.list[index];
					var item: clt_stiker = new clt_stiker(_scroll, inner.x, inner.y, 'userPhoto', null);
					item._data = a_data;
					item.resize(inner.width, inner.height);
					item.setID(a_data.id, 80);
					return item;
				});
				inner.top += STIKERSHEIGHT;
			}
			
			info = new uif_label(panel, inner.x, inner.y, inner.width, 20, 'desc');
			info.text = clt.locale.INPUTNAMEGAME;
			
			_input = new uif_input(panel, inner.x, inner.bottom - 20, inner.width, 20, 'minput');
		}
		
		public function get nameCollage(): String {
			return _input.text;
		}
		
		public function get stiker(): int {
			return (_stikers && _stikers.selectItem)?_stikers.selectItem.object.id:0;
		}
	}
}